/**
 * 
 */
package com.meetingshow.privilege.dao;

import java.util.List;

import com.meetingshow.common.base.dao.BaseDAO;
import com.meetingshow.common.base.dao.model.QueryStruct;
import com.meetingshow.common.base.service.model.QueryResults;
import com.meetingshow.privilege.dao.model.UserPO;

/**
 * @author louyi
 *
 */
public class UserDAO extends BaseDAO {
    public Integer saveUser(UserPO userPO) throws Exception {
        return (Integer) this.saveBaseObj(userPO);
    }

    public void updateUser(UserPO userPO) throws Exception {
        this.updateBaseObj(userPO);
    }

    public void removeUser(UserPO userPO) throws Exception {
        this.deleteBaseObj(userPO);
    }
    
    public UserPO loadUserById(Integer userId) throws Exception {
        return this.queryById(UserPO.class, userId);
    }
    
    public QueryResults<UserPO> queryUser(QueryStruct queryStruct) throws Exception {
        QueryResults<UserPO> queryResults = new QueryResults<UserPO>();
        List<UserPO> resultList = findByParameter(queryStruct);
        queryResults.setResultList(resultList);
        if (queryStruct.getFirstResultNo() != null
                && queryStruct.getResultsPerGroup() != null) {
            queryResults = queryPageInfo(queryStruct, queryResults);
        } else {
            queryResults.setTotalResultsNum(Long.valueOf(resultList.size()));
        }
        return queryResults;
    }
}
